﻿using CleanArchitecture.Infrastructure.Interfaces;
using System.Collections.Generic;

namespace CleanArchitecture.Infrastructure.Entities.Settings
{
    /// <summary>
    /// Security settings
    /// </summary>
    public class SecuritySettings : ISettings
    {
        private string _loginverifytype;
        private string _customerloginverify;
        /// <summary>
        /// Gets or sets a value indicating whether all pages will be forced to use SSL (no matter of a specified [HttpsRequirementAttribute] attribute)
        /// </summary>
        public bool ForceSslForAllPages { get; set; }

        /// <summary>
        /// Gets or sets an encryption key
        /// </summary>
        public string EncryptionKey { get; set; }

        /// <summary>
        /// Gets or sets a list of admin area allowed IP addresses
        /// </summary>
        public List<string> AdminAreaAllowedIpAddresses { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether XSRF protection for admin area should be enabled
        /// </summary>
        public bool EnableXsrfProtectionForAdminArea { get; set; }

        /// <summary>
        /// Gets or sets 设置后台用户登录验证方式：可选： captcha, slider, no
        /// </summary>
        public string BackendLoginVerifyType
        {
            get
            {
                return string.IsNullOrEmpty(_loginverifytype) 
                    ? "captcha" 
                    : _loginverifytype.ToLower();
            }
            set => _loginverifytype = value;
        }

        /// <summary>
        /// 用户后台登录方式，逗号分隔组合启用多种后台登录方式
        /// 可选LoginName,Mobile,Email
        /// 例 ：如只采用LoginName+Mobile登录，则修改数据库字段为loginname,mobile
        /// </summary>
        public List<string> AdminUserLogin { get; set; }

        /// <summary>
        /// 用户前端登录校验方式: passwordandcaptcha/smscode  
        /// passwordandcaptcha : 密码加图形验证码
        /// smscode: 短信验证码
        /// </summary>
        public string CustomerLoginVerify
        {
            get
            {
                return string.IsNullOrEmpty(_customerloginverify)
                    ? "passwordandcaptcha"
                    : _customerloginverify.ToLower();
            }
            set
            {
                _customerloginverify = value;
            }
        }
        /// <summary>
        /// 用户前端登录方式，逗号分隔组合启用多种后台登录方式
        /// 可选LoginName,Mobile,Email
        /// 例 ：如只采用LoginName+Mobile登录，则修改数据库字段为loginname,mobile
        /// </summary>
        public List<string> CustomerLogin { get; set; }
        /// <summary>
        /// Get or set the expiration time of logineduser's cookie 
        /// </summary>
        public int? CookieExpiredPeriod { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to allow non-ASCII characters in headers
        /// </summary>
        public bool AllowNonAsciiCharactersInHeaders { get; set; }

        public string JwtValidIssuer { get; set; }
        public string JwtValidAudience { get; set; }
        public string JwtIssuerSigningKey { get; set; }
        public int JwtExpirationMinutes { get; set; }
    }
}